package org.gap.service;

import java.util.List;
import java.util.Set;

import org.gap.domain.Adresses;
import org.gap.domain.CodesPostaux;
import org.gap.domain.Pays;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/GAP_v2-security-context.xml",
		"file:./resources/GAP_v2-service-context.xml",
		"file:./resources/GAP_v2-dao-context.xml",
		"file:./resources/GAP_v2-web-context.xml" })
@Transactional
public class CodesPostauxServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected CodesPostauxService service;

	/**
	 * Instantiates a new CodesPostauxServiceTest.
	 *
	 */
	public CodesPostauxServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 * Save an existing Pays entity
	 * 
	 */
	@Test
	public void saveCodesPostauxPays() {
		// TODO: JUnit - Populate test inputs for operation: saveCodesPostauxPays 
		String cdpPays = null;
		String cdpCodePostal = null;
		String cdpNInsee = null;
		String cdpLocalite = null;
		Pays related_pays = new org.gap.domain.Pays();
		CodesPostaux response = null;
		response = service.saveCodesPostauxPays(cdpPays, cdpCodePostal, cdpNInsee, cdpLocalite, related_pays);
		// TODO: JUnit - Add assertions to test outputs of operation: saveCodesPostauxPays
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Pays entity
	 * 
	 */
	@Test
	public void deleteCodesPostauxPays() {
		// TODO: JUnit - Populate test inputs for operation: deleteCodesPostauxPays 
		String codespostaux_cdpPays = null;
		String codespostaux_cdpCodePostal = null;
		String codespostaux_cdpNInsee = null;
		String codespostaux_cdpLocalite = null;
		String related_pays_pppPays = null;
		CodesPostaux response = null;
		response = service.deleteCodesPostauxPays(codespostaux_cdpPays, codespostaux_cdpCodePostal, codespostaux_cdpNInsee, codespostaux_cdpLocalite, related_pays_pppPays);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteCodesPostauxPays
	}

	/**
	 * Operation Unit Test
	 * Return all CodesPostaux entity
	 * 
	 */
	@Test
	public void findAllCodesPostauxs() {
		// TODO: JUnit - Populate test inputs for operation: findAllCodesPostauxs 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<CodesPostaux> response = null;
		response = service.findAllCodesPostauxs(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllCodesPostauxs
	}

	/**
	 * Operation Unit Test
	 * Save an existing Adresses entity
	 * 
	 */
	@Test
	public void saveCodesPostauxAdresseses() {
		// TODO: JUnit - Populate test inputs for operation: saveCodesPostauxAdresseses 
		String cdpPays_1 = null;
		String cdpCodePostal_1 = null;
		String cdpNInsee_1 = null;
		String cdpLocalite_1 = null;
		Adresses related_adresseses = new org.gap.domain.Adresses();
		CodesPostaux response = null;
		response = service.saveCodesPostauxAdresseses(cdpPays_1, cdpCodePostal_1, cdpNInsee_1, cdpLocalite_1, related_adresseses);
		// TODO: JUnit - Add assertions to test outputs of operation: saveCodesPostauxAdresseses
	}

	/**
	 * Operation Unit Test
	 * Load an existing CodesPostaux entity
	 * 
	 */
	@Test
	public void loadCodesPostauxs() {
		Set<CodesPostaux> response = null;
		response = service.loadCodesPostauxs();
		// TODO: JUnit - Add assertions to test outputs of operation: loadCodesPostauxs
	}

	/**
	 * Operation Unit Test
	 * Save an existing CodesPostaux entity
	 * 
	 */
	@Test
	public void saveCodesPostaux() {
		// TODO: JUnit - Populate test inputs for operation: saveCodesPostaux 
		CodesPostaux codespostaux = new org.gap.domain.CodesPostaux();
		service.saveCodesPostaux(codespostaux);
	}

	/**
	 * Operation Unit Test
	 * Return a count of all CodesPostaux entity
	 * 
	 */
	@Test
	public void countCodesPostauxs() {
		Integer response = null;
		response = service.countCodesPostauxs();
		// TODO: JUnit - Add assertions to test outputs of operation: countCodesPostauxs
	}

	/**
	 * Operation Unit Test
	 * Delete an existing CodesPostaux entity
	 * 
	 */
	@Test
	public void deleteCodesPostaux() {
		// TODO: JUnit - Populate test inputs for operation: deleteCodesPostaux 
		CodesPostaux codespostaux_1 = new org.gap.domain.CodesPostaux();
		service.deleteCodesPostaux(codespostaux_1);
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findCodesPostauxByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findCodesPostauxByPrimaryKey 
		String cdpPays_2 = null;
		String cdpCodePostal_2 = null;
		String cdpNInsee_2 = null;
		String cdpLocalite_2 = null;
		CodesPostaux response = null;
		response = service.findCodesPostauxByPrimaryKey(cdpPays_2, cdpCodePostal_2, cdpNInsee_2, cdpLocalite_2);
		// TODO: JUnit - Add assertions to test outputs of operation: findCodesPostauxByPrimaryKey
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Adresses entity
	 * 
	 */
	@Test
	public void deleteCodesPostauxAdresseses() {
		// TODO: JUnit - Populate test inputs for operation: deleteCodesPostauxAdresseses 
		String codespostaux_cdpPays_1 = null;
		String codespostaux_cdpCodePostal_1 = null;
		String codespostaux_cdpNInsee_1 = null;
		String codespostaux_cdpLocalite_1 = null;
		Integer related_adresseses_addAdresse = 0;
		CodesPostaux response = null;
		response = service.deleteCodesPostauxAdresseses(codespostaux_cdpPays_1, codespostaux_cdpCodePostal_1, codespostaux_cdpNInsee_1, codespostaux_cdpLocalite_1, related_adresseses_addAdresse);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteCodesPostauxAdresseses
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
